#*****************************************************************************************************
#* FILE: string-handling.asm
#*
#* DECRIPTION
#* Write a program that converts the string to all lower case characters. Do this
#* by adding 0x20 to each character in the string.
#*
#* AUTHORS
#* Joe Boeding (Joe.Boeding@asu.edu) [JB]
#* Taylor Wood (Taylor.D.Wood@asu.edu) [TW]
#*
#* Computer Science & Engineering
#* CSE420 Computer Architecture I, Spring 2014
#*
#* MODIFICATION HISTORY
#* --------------------------------------------------------------------------------------------------
#* Initial implement	[JB][TW]
#****************************************************************************************************
.data
	string:		.asciiz		"ABCDEFG"
	size:		.word		7
	
# Instrctions go below
.text

# Load the string into a register
la $s0, string  # holds the location of the base address
la $t5, string	# temp address to manipulate through
lw $t1, size	# length of the string
li $t3, 0	# i

# This loops manipulates each character one at a time
loop:
	
	lb $t2, 0($t5)		# load the character
	addi $t2, $t2, 0x20	# switch character to lowercase
	addi $t3, $t3, 1	# i++

	sb $t2, 0($t5)		# Store the byte back into the address it was loaded from

	addi $t5, $t5, 1 	# increment the address

	blt $t3, $t1, loop	# if we haven't reached the end of the string, increment

# move the address of the string to argument register
move $a0, $s0

li $v0, 4
syscall		# print the reversed string

# Terminate the program
li $v0, 10  # Syscall number 10 is to terminate the program
syscall     # exit now
